package com.sunwayworld.basemodule.business.batchrevise.service.impl;

import com.sunwayworld.basemodule.business.batchrevise.bean.LimsSampleTempBean;
import com.sunwayworld.basemodule.business.batchrevise.dao.LimsSampleTempDao;
import com.sunwayworld.basemodule.business.batchrevise.service.LimsSampleTempService;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@GikamBean
public class LimsSampleTempServiceImpl implements LimsSampleTempService {

    @Autowired
    private LimsSampleTempDao limsSampleTempDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsSampleTempDao getDao() {
        return limsSampleTempDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsSampleTempBean sampleTempBean = jsonWrapper.parseUnique(LimsSampleTempBean.class);
        sampleTempBean.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(sampleTempBean);
        return sampleTempBean.getId();
    }

}
